{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-10-17T08:40:42.422323Z",
     "start_time": "2024-10-17T08:40:42.066075Z"
    }
   },
   "source": [
    "import numpy as np\n",
    "import json"
   ],
   "outputs": [],
   "execution_count": 1
  },
  {
   "cell_type": "code",
   "source": "array = np.load(r\"C:\\Users\\masaikk\\Downloads\\FaceTalk_170731_00024_TA_sentence21.npy\")",
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-17T08:41:25.271247Z",
     "start_time": "2024-10-17T08:41:25.259278Z"
    }
   },
   "id": "48390df6b8e9f108",
   "outputs": [],
   "execution_count": 2
  },
  {
   "cell_type": "code",
   "source": [
    "\n",
    "# 将numpy数组中的每个浮点数四舍五入到小数点后7位\n",
    "rounded_array = np.round(array, 7)\n",
    "\n",
    "# 将numpy数组转换为Python列表\n",
    "array_list = rounded_array.tolist()\n",
    "\n",
    "# 将Python列表转换为JSON格式的字符串\n",
    "json_str = json.dumps(array_list)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-17T08:41:30.278039Z",
     "start_time": "2024-10-17T08:41:27.266149Z"
    }
   },
   "id": "1e281ad29c14ee44",
   "outputs": [],
   "execution_count": 3
  },
  {
   "cell_type": "code",
   "source": [
    "with open('output.json', 'w') as json_file:\n",
    "    json_file.write(json_str)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-17T08:41:33.617197Z",
     "start_time": "2024-10-17T08:41:33.390161Z"
    }
   },
   "id": "b371566d0aa10e16",
   "outputs": [],
   "execution_count": 4
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   },
   "id": "749e7fb2998bf9d2",
   "execution_count": null
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
